#define PROC_CLASS_SYS 0 //for class - defines system processes
#define PROC_CLASS_APP 1 //for class - defines application processes
#define PROC_NAME_LEN 9 //length, including /0, for process name
#define PROC_STACK_SIZE 0x400 //bytes alloted for PCB stack
#define PROC_STATE_RUNNING 1 //for state flag: running
#define PROC_STATE_READY 0 //for state flag: ready
#define PROC_STATE_BLOCKED -1 //for state flag: blocked
#define PROC_SUSP 1 //for suspended flag
#define PROC_NOT_SUSP 0 //for not suspended flag

// PCB structure
 
 typedef struct PCB{
	char name[9];
	//application or system
	int type; 
	//values between -128 and 127, inclusive. higher = greater priority
	int priority;
	//running, ready, or blocked state
	int state;
	//suspended or not suspended
	int suspended; 
	//unsigned char stack_area[PROC_STACK_SIZE];
	//stack grows from high to low in 8086 architecture
	unsigned char *stack_top; 
	//initialize stack_top to highest address + 1, points to lowest occupied address
	//points to base
	unsigned char *stack_base; 
	//memory description information - used for instruction code and static data
	int mem_size;
	//start of mem area into which process to be loaded
	unsigned char *mem_load_address; 
	//address at which executing should begin
	unsigned char *mem_exec_address; 
	//pointer for next PCB in queue
	struct pcb *next; 
	//pointer to previous PCB in queue
	struct pcb *prev; 
} ;

typedef struct PCB pcb; // can use either PCB or pcb, both should reference the same item

pcb *allocate_PCB(void); 

pcb *setup_PCB(char name[], int type, int priorty);

int check_name(char name[]);
pcb *traverse_find(pcb *head, char name[]);
pcb *find_pcb(char name[]);

pcb *traverse(pcb * head, int priority);

pcb *get_ready_head();

int insert_pcb(pcb *this_pcb, int state, int suspended);

int free_pcb(pcb *this_pcb);

int remove_pcb(pcb *this_pcb);

void show_all_pcbs(void);
void show_all_ready(void);
void show_all_blocked(void);
void show_all_suspended_ready(void);
void show_all_suspended_blocked(void);

void terminate_cleanup(void);
